package com.coocaa.ops.admin.v1.hvi.biz;

import com.coocaa.ops.admin.v1.hvi.mapper.IHistoryVersionInfoMapper;
import com.coocaa.ops.admin.v1.hvi.model.HistoryVersionInfoEntity;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.Map;

/**
 * @author tangminghong
 * @date 2019-10-08
 */
@Service
public class HistoryVersionInfoBizImpl implements IHistoryVersionInfoBiz {

    @Autowired
    private IHistoryVersionInfoMapper historyVersionInfoMapper;

    /**
     * 获取版本信息
     *
     * @param resourceType
     * @param resourceId
     * @return 返回版本与版本信息对应的map
     */
    @Override
    public Map<Integer, HistoryVersionInfoEntity> getHistoryInfo(String resourceType, Integer resourceId) {
        return historyVersionInfoMapper.getHistoryInfo(resourceType, resourceId, null, null, null);
    }

    @Override
    public Map<Integer, HistoryVersionInfoEntity> getHistoryInfo(String resourceType, Integer resourceId, Integer limit, Integer earliestVersion) {
        return historyVersionInfoMapper.getHistoryInfo(resourceType, resourceId,  null, limit, earliestVersion);
    }

    @Override
    public void addHistoryInfo(String resourceType, Integer resourceId, Integer resourceVersion, Integer userId, Date launchDate) {
        historyVersionInfoMapper.addHistoryInfo(resourceType, resourceId, resourceVersion, userId, launchDate);
    }

    @Override
    public Date getEarliestLaunchDate(Date date, String resourceType, Integer resourceId) {
        return historyVersionInfoMapper.getEarliestLaunchDate(date, resourceType, resourceId);
    }
}
